package com.ice.work.moment.crawler.dao.share;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ice.work.moment.facade.crawler.model.Share;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * @Description user dao
 * @Author DELL
 * @Create 2019-01-10
 * @Since 1.0.0
 */
@Repository
public class ShareRepository extends ServiceImpl<IShareMapper, Share> implements IShareRepository {


    @Override
    public Share findByShareCodeAndDataStatus(String stockCode, Integer dataStatus) {
        return this.baseMapper.selectOne(new QueryWrapper<Share>().lambda().eq(Share::getCode, stockCode).eq(Share::getDataStatus, dataStatus));
    }

    @Override
    public List<Share> findByShareCodeInAndDataStatus(Collection<String> stockCodes, Integer dataStatus) {
        return this.baseMapper.selectList(new QueryWrapper<Share>().lambda().in(Share::getCode, stockCodes).eq(Share::getDataStatus, dataStatus));
    }

    @Override
    public IPage<Share> page(IPage<Share> page) {
        return this.baseMapper.page(page);
    }

    @Override
    public Share findByIdAndDataStatus(Long id, Integer dataStatus) {
        return this.baseMapper.selectOne(new QueryWrapper<Share>().lambda().eq(Share::getId, id).eq(Share::getDataStatus, dataStatus));
    }
}


